unit upasclientcocashdrawer;
{$I LogOption.txt}

interface
uses
  SysUtils,
  upasclientco;

type
  EOupasclientcocashdrawer = class(EOupasclientco)
  private
    // CashDrawer Properties
    FCapStatus: WordBool;
    FCapStatusMultiDrawerDetect: WordBool;
    FDrawerOpened: WordBool;

  protected
    function AssignProperty(NodeName, NodeValue: String): String; override;

    // CashDrawer Properties getter/setter
    function getCapStatus: WordBool; virtual;
    function getCapStatusMultiDrawerDetect: WordBool; virtual;
    function getDrawerOpened: WordBool; virtual;

    // CashDrawer Properties
    property CapStatus: WordBool read getCapStatus;
    property CapStatusMultiDrawerDetect: WordBool read getCapStatusMultiDrawerDetect;
    property DrawerOpened: WordBool read getDrawerOpened;

  public
    // CashDrawer Methods
    function OpenDrawer: Integer;
    function WaitForDrawerClose(BeepTimeout: Integer; BeepFrequency: Integer; BeepDuration: Integer; BeepDelay: Integer): Integer;

  end;

implementation
uses
  upasxml;

function EOupasclientcocashdrawer.AssignProperty(NodeName, NodeValue: String): String;
begin
  Result := '';

  if NodeName = xmltagCapStatus then
    FCapStatus := WordBool(StrToint(NodeValue))
  else if NodeName = xmltagCapStatusMultiDrawerDetect then
    FCapStatusMultiDrawerDetect := WordBool(StrToint(NodeValue))
  else if NodeName = xmltagDrawerOpened then
    FDrawerOpened := WordBool(StrToint(NodeValue))
  else
    Inherited AssignProperty(NodeName, NodeValue);
end;

function EOupasclientcocashdrawer.getCapStatus: WordBool;
begin
  Result := FCapStatus;
end;

function EOupasclientcocashdrawer.getCapStatusMultiDrawerDetect: WordBool;
begin
  Result := FCapStatusMultiDrawerDetect;
end;

function EOupasclientcocashdrawer.getDrawerOpened: WordBool;
begin
  Result := FDrawerOpened;
end;

function EOupasclientcocashdrawer.OpenDrawer: Integer;
begin
  Result := SendCommand('<xml><Method Name="OpenDrawer"></Method></xml>');
end;

function EOupasclientcocashdrawer.WaitForDrawerClose(BeepTimeout: Integer; BeepFrequency: Integer; BeepDuration: Integer; BeepDelay: Integer): Integer;
begin
  Result := SendCommand('<xml><Method Name="WaitForDrawerClose" BeepTimeout="' + IntToStr(BeepTimeout) + '" BeepFrequency="' + IntToStr(BeepFrequency) + '" BeepDuration="' + IntToStr(BeepDuration) + '" BeepDelay="' + IntToStr(BeepDelay) + '"></Method></xml>');
end;

end.
